package com.sfh.gd.controller;

import cn.dev33.satoken.util.SaResult;
import com.sfh.gd.domain.dto.*;
import com.sfh.gd.domain.dto.web.*;
import com.sfh.gd.domain.query.GamePageQuery;
import com.sfh.gd.service.GameService;
import com.sfh.gd.service.GameTeamService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 赛事
 */
@RestController
@RequestMapping("/api/game")
@RequiredArgsConstructor
public class WebGameController {

    private final GameService gameService;
    private final GameTeamService gameTeamService;
    /**
     * 新增赛事
     * @return
     */
    @PostMapping("/add")
    public SaResult addGame(@RequestBody GameNewDTO data) {
        return gameService.addGame(data);
    }

    /**
     * 修改赛事
     * @param data
     * @return
     */
    @PostMapping("/edit")
    public SaResult editGame(@RequestBody GameEditDTO data) {
        return gameService.editGame(data);
    }

    /**
     * 删除赛事
     * @param gameId
     * @return
     */
    @PostMapping("/delete")
    public SaResult deleteGame(@RequestParam("gameId") Long gameId) {
        return gameService.deleteGame(gameId);
    }

    /**
     * 获取赛事列表
     * @return 赛事列表
     */
    @GetMapping("/getGamePage")
    public  SaResult getGamePage(@RequestBody  GamePageQuery pageQuery){
        return gameService.getGamePage(pageQuery);
    }


    /**
     * 获取赛事详情
     *
     * @param gameId 赛事id
     * @return 赛事详情
     */
    @GetMapping("/getGamePage")
    public SaResult getGameDetail(@RequestParam("gameId") Long gameId){
        return gameService.getGameDetail(gameId);
    }

    /**
     * 查询当天赛事
     */
    @GetMapping("/getTodayGame")
    public  SaResult getTodayGame(){
        return gameService.getTodayGame();
    }

    /**
     * 更新赛事状态  1-报名中(默认值)  2-比赛进行中 3-比赛已结束 4比赛已取消
     * @return
     */
    @PostMapping("/changeState")

    public SaResult changeState(@RequestBody GameStateDO data){
        return gameService.changeState(data);
    }
    /**
     * 获取赛事积分排名
     */
    @GetMapping("/getGameRank")
    public SaResult getGameRank(@RequestParam("gameId") Long gameId){
        return  gameTeamService.getGameRank(gameId);
    }

    /**
     *  PC平台添加添加选手报名
     */
    @PostMapping("/signUp")
    public SaResult signUp(@RequestBody SysGameSignUpDTO data){
        return  gameTeamService.signUp(data);
    }

    /**
     *平台更换队伍中换人(新增替换)
     */
    @PostMapping("/changeTeamMember")
    public SaResult changeTeamMember(@RequestBody ChangeMemberDTO data){
        return  gameTeamService.changeTeamMember(data);
    }

    /**
     *平台更换队伍中换人(选择已报名未组队人员替换)
     */
    @PostMapping("/selectChangeTeamMember")
    public SaResult selectChangeTeamMember(@RequestBody ChangeMember2DTO data){
        return  gameTeamService.selectChangeTeamMember( data);
    }

    /**
     * PC平台操作取消报名
     */
    @PostMapping("/cancelSignUp")
    public SaResult cancelSignUp(@RequestBody SysGameCancelSignUpDTO data){
        return gameTeamService.cancelSignUp(data);
    }

    /**
     * 解散队伍
     */
    @PostMapping("/dismissTeam")
    public SaResult dismissTeam(@RequestParam("teamId") Long teamId){
        return gameTeamService.dismissTeam(teamId);
    }

    /**
     * 获取赛事-所有报名人员列表（已组队，未组队）
     * @return
     */
    @GetMapping("/getGameAllUserTeam")
    public SaResult getGameAllUserTeam(@RequestParam("gameId") Long gameId){
        return  gameTeamService.getGameAllUserTeam(gameId);
    }


    /**
     * PK队伍弃权
     */
    @PostMapping("/teamAbandon")
    public SaResult teamAbandon(@RequestBody PKAbandonTeamDTO data){
        //TODO
        return  SaResult.ok();
    }

    /**
     * 获取队伍赛事所有对阵信息
     */
    @GetMapping("/getPKInfo")
    public SaResult getPKInfo(@RequestParam("teamId") Long teamId){
        //TODO
        return  SaResult.ok();
    }

    /**
     * 获取PK对阵详情信息
     */
    @GetMapping("/getPKInfoNew")
    public SaResult getPKInfoNew(@RequestParam("teamId") Long pkId){
        //TODO
        return  SaResult.ok();
    }

    /**
     * 录入对阵结果
     */
    @PostMapping("/addPKResult")
    public SaResult addPKResult(@RequestBody PKResultNewDTO data){
        //TODO 返回
        return  SaResult.ok();
    }

    /**
     * 创建队伍赛事PK信息
     */
    @PostMapping("/addPKInfo")
    public SaResult addPKInfo(@RequestBody PKInfoNewDTO data){
        //TODO
        return  SaResult.ok();
    }
}
